import request from "@/utils/request";
import {
  HospitalDetailRes,
  HospitalDepartmentRes,
  PhoneCodeRes,
  UserInfoRes,
  LoginData,
} from "./type";

enum API {
  HOSPITAL_DETAIL_URL = "/hosp/hospital/",
  HOSPITAL_DEPARTMENT_URL = "/hosp/hospital/department/",
  GET_USER_CODE_URL = "/sms/send/",
  USER_LOGIN_URL = "/user/login",
}

// 获取医院详情的接口
export const reqHospitalDetail = (hoscode: string) =>
  request.get<any, HospitalDetailRes>(API.HOSPITAL_DETAIL_URL + hoscode);

// 获取医院科室的接口
export const reqHospitalDepartment = (hoscode: string) =>
  request.get<any, HospitalDepartmentRes>(
    API.HOSPITAL_DEPARTMENT_URL + hoscode
  );

// 根据手机号获取验证码的接口
export const reqUserCode = (phone: string) =>
  request.get<any, PhoneCodeRes>(API.GET_USER_CODE_URL + phone);

//
export const reqUserLogin = (data: LoginData) =>
  request.post<any, UserInfoRes>(API.USER_LOGIN_URL, data);
